# -*- coding: utf-8 -*-

###########################################################################
## Python code generated with wxFormBuilder (version Oct 26 2018)
## http://www.wxformbuilder.org/
##
## PLEASE DO *NOT* EDIT THIS FILE!
###########################################################################

import wx
import wx.xrc
import sys
import psutil
import platform


###########################################################################
## Class MyFrame1
###########################################################################

class pc_info(wx.Frame):

    def __init__(self, parent):
        wx.Frame.__init__(self, parent, id=wx.ID_ANY, title=wx.EmptyString, pos=wx.DefaultPosition,
                          size=wx.Size(800, 600), style=wx.DEFAULT_FRAME_STYLE | wx.TAB_TRAVERSAL)

        self.SetSizeHints(wx.DefaultSize, wx.DefaultSize)

        bSizer1 = wx.BoxSizer(wx.VERTICAL)

        bSizer1.Add((0, 0), 1, wx.EXPAND, 5)

        bSizer2 = wx.BoxSizer(wx.HORIZONTAL)

        bSizer2.Add((0, 0), 1, wx.EXPAND, 5)

        self.m_staticText1 = wx.StaticText(self, wx.ID_ANY, u"计算机名称：", wx.DefaultPosition, wx.Size(120, -1), 0)
        self.m_staticText1.Wrap(-1)

        bSizer2.Add(self.m_staticText1, 0, wx.ALL, 5)

        self.m_name = wx.StaticText(self, wx.ID_ANY, u"MyLabel", wx.DefaultPosition, wx.DefaultSize, 0)
        self.m_name.Wrap(-1)

        bSizer2.Add(self.m_name, 0, wx.ALL, 5)

        bSizer2.Add((0, 0), 1, wx.EXPAND, 5)

        bSizer1.Add(bSizer2, 1, wx.EXPAND, 5)

        bSizer5 = wx.BoxSizer(wx.HORIZONTAL)

        bSizer5.Add((0, 0), 1, wx.EXPAND, 5)

        self.m_staticText3 = wx.StaticText(self, wx.ID_ANY, u"计算机操作系统：", wx.DefaultPosition, wx.Size(120, -1), 0)
        self.m_staticText3.Wrap(-1)

        bSizer5.Add(self.m_staticText3, 0, wx.ALL, 5)

        self.m_os = wx.StaticText(self, wx.ID_ANY, u"MyLabel", wx.DefaultPosition,
                                  wx.DefaultSize, 0)
        self.m_os.Wrap(-1)

        bSizer5.Add(self.m_os, 0, wx.ALL, 5)

        bSizer5.Add((0, 0), 1, wx.EXPAND, 5)

        bSizer1.Add(bSizer5, 1, wx.EXPAND, 5)

        bSizer6 = wx.BoxSizer(wx.HORIZONTAL)

        bSizer6.Add((0, 0), 1, wx.EXPAND, 5)

        self.m_staticText5 = wx.StaticText(self, wx.ID_ANY, u"域名：", wx.DefaultPosition, wx.Size(120, -1), 0)
        self.m_staticText5.Wrap(-1)

        bSizer6.Add(self.m_staticText5, 0, wx.ALL, 5)

        self.m_fname = wx.StaticText(self, wx.ID_ANY, u"MyLabel", wx.DefaultPosition, wx.DefaultSize, 0)
        self.m_fname.Wrap(-1)

        bSizer6.Add(self.m_fname, 0, wx.ALL, 5)

        bSizer6.Add((0, 0), 1, wx.EXPAND, 5)

        bSizer1.Add(bSizer6, 1, wx.EXPAND, 5)

        bSizer7 = wx.BoxSizer(wx.HORIZONTAL)

        bSizer7.Add((0, 0), 1, wx.EXPAND, 5)

        self.m_staticText7 = wx.StaticText(self, wx.ID_ANY, u"系统制造商：", wx.DefaultPosition, wx.Size(120, -1), 0)
        self.m_staticText7.Wrap(-1)

        bSizer7.Add(self.m_staticText7, 0, wx.ALL, 5)

        self.m_maker = wx.StaticText(self, wx.ID_ANY, u"MyLabel", wx.DefaultPosition, wx.DefaultSize, 0)
        self.m_maker.Wrap(-1)

        bSizer7.Add(self.m_maker, 0, wx.ALL, 5)

        bSizer7.Add((0, 0), 1, wx.EXPAND, 5)

        bSizer1.Add(bSizer7, 1, wx.EXPAND, 5)

        bSizer8 = wx.BoxSizer(wx.HORIZONTAL)

        bSizer8.Add((0, 0), 1, wx.EXPAND, 5)

        self.m_staticText9 = wx.StaticText(self, wx.ID_ANY, u"系统型号：", wx.DefaultPosition, wx.Size(120, -1), 0)
        self.m_staticText9.Wrap(-1)

        bSizer8.Add(self.m_staticText9, 0, wx.ALL, 5)

        self.m_size = wx.StaticText(self, wx.ID_ANY, u"MyLabel", wx.DefaultPosition, wx.DefaultSize, 0)
        self.m_size.Wrap(-1)

        bSizer8.Add(self.m_size, 0, wx.ALL, 5)

        bSizer8.Add((0, 0), 1, wx.EXPAND, 5)

        bSizer1.Add(bSizer8, 1, wx.EXPAND, 5)

        bSizer9 = wx.BoxSizer(wx.HORIZONTAL)

        bSizer9.Add((0, 0), 1, wx.EXPAND, 5)

        self.m_staticText11 = wx.StaticText(self, wx.ID_ANY, u"处理器数：", wx.DefaultPosition, wx.Size(120, -1), 0)
        self.m_staticText11.Wrap(-1)

        bSizer9.Add(self.m_staticText11, 0, wx.ALL, 5)

        self.m_cnum = wx.StaticText(self, wx.ID_ANY, u"MyLabel", wx.DefaultPosition,
                                    wx.DefaultSize, 0)
        self.m_cnum.Wrap(-1)

        bSizer9.Add(self.m_cnum, 0, wx.ALL, 5)

        bSizer9.Add((0, 0), 1, wx.EXPAND, 5)

        bSizer1.Add(bSizer9, 1, wx.EXPAND, 5)

        bSizer10 = wx.BoxSizer(wx.HORIZONTAL)

        bSizer10.Add((0, 0), 1, wx.EXPAND, 5)

        self.m_staticText13 = wx.StaticText(self, wx.ID_ANY, u"处理器：", wx.DefaultPosition, wx.Size(120, -1), 0)
        self.m_staticText13.Wrap(-1)

        bSizer10.Add(self.m_staticText13, 0, wx.ALL, 5)

        self.m_cpu = wx.StaticText(self, wx.ID_ANY, u"MyLabel", wx.DefaultPosition, wx.DefaultSize, 0)
        self.m_cpu.Wrap(-1)

        bSizer10.Add(self.m_cpu, 0, wx.ALL, 5)

        bSizer10.Add((0, 0), 1, wx.EXPAND, 5)

        bSizer1.Add(bSizer10, 1, wx.EXPAND, 5)

        bSizer11 = wx.BoxSizer(wx.HORIZONTAL)

        bSizer11.Add((0, 0), 1, wx.EXPAND, 5)

        self.m_staticText15 = wx.StaticText(self, wx.ID_ANY, u"内存：", wx.DefaultPosition, wx.Size(120, -1), 0)
        self.m_staticText15.Wrap(-1)

        bSizer11.Add(self.m_staticText15, 0, wx.ALL, 5)

        self.m_memory = wx.StaticText(self, wx.ID_ANY, u"MyLabel", wx.DefaultPosition, wx.DefaultSize, 0)
        self.m_memory.Wrap(-1)

        bSizer11.Add(self.m_memory, 0, wx.ALL, 5)

        bSizer11.Add((0, 0), 1, wx.EXPAND, 5)

        bSizer1.Add(bSizer11, 1, wx.EXPAND, 5)

        bSizer12 = wx.BoxSizer(wx.HORIZONTAL)

        bSizer12.Add((0, 0), 1, wx.EXPAND, 5)

        self.m_staticText17 = wx.StaticText(self, wx.ID_ANY, u"剩余物理内存：", wx.DefaultPosition, wx.Size(120, -1), 0)
        self.m_staticText17.Wrap(-1)

        bSizer12.Add(self.m_staticText17, 0, wx.ALL, 5)

        self.m_rmemory = wx.StaticText(self, wx.ID_ANY, u"MyLabel", wx.DefaultPosition, wx.DefaultSize, 0)
        self.m_rmemory.Wrap(-1)

        bSizer12.Add(self.m_rmemory, 0, wx.ALL, 5)

        bSizer12.Add((0, 0), 1, wx.EXPAND, 5)

        bSizer1.Add(bSizer12, 1, wx.EXPAND, 5)

        bSizer1.Add((0, 0), 1, wx.EXPAND, 5)

        self.SetSizer(bSizer1)
        self.Layout()

        self.Centre(wx.BOTH)
        self.getSysInfo()

    def __del__(self):
        pass

    def getSysInfo(self):
        if sys.platform == "win32":
            import wmi
            Wmi = wmi.WMI()
            CS = Wmi.Win32_ComputerSystem()[0]
            CPU = Wmi.Win32_Processor()[0]
            OS = Wmi.Win32_OperatingSystem()[0]

            self.m_name.SetLabel(platform.node())
            self.m_os.SetLabel(platform.system())
            self.m_fname.SetLabel(CS.Domain)
            self.m_maker.SetLabel(CS.Manufacturer)
            self.m_size.SetLabel(CS.Model)
            self.m_cnum.SetLabel(str(psutil.cpu_count()))
            self.m_cpu.SetLabel(CPU.name)
            self.m_memory.SetLabel(str(int(CS.TotalPhysicalMemory)//1024**2)+u"MB")
            self.m_rmemory.SetLabel(str(int(OS.FreePhysicalMemory)//1024)+u"MB")


class myapp(wx.App):
    def OnInit(self):
        myframe = pc_info(None)

        myframe.Show(True)

        return True


if __name__ == '__main__':
    app = myapp()
    app.MainLoop()
